feat: implement RestRedisCache and RedisClient for REST-based Redis s…#1
Open
DanielDango wants to merge 1 commit into
Open
feat: implement RestRedisCache and RedisClient for REST-based Redis s…#1DanielDango wants to merge 1 commit into
DanielDango wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a REST-backed Redis cache path alongside the existing Jedis-backed Redis cache, using a shared Redis client abstraction.
Changes:
- Introduces
UnifiedRedisClientplus Jedis and REST Redis adapters. - Adds
RestRedisCacheand factory support forrest_redis. - Adds the
org.fuchss:rest-redisdependency and REST Redis integration tests.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/UnifiedRedisClient.java |
Adds common Redis operation interface. |
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RedisAdapter.java |
Wraps Jedis behind the new interface. |
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RestRedisAdapter.java |
Wraps REST Redis client behind the new interface. |
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RedisCache.java |
Refactors Redis cache to use the abstraction and adds injected-client constructor/exists method. |
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RestRedisCache.java |
Adds REST Redis cache implementation and environment-based connection setup. |
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/Cache.java |
Adds case-insensitive factory selection and rest_redis support. |
src/test/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RestRedisIntegrationTest.java |
Adds integration tests for REST Redis cache behavior. |
pom.xml |
Adds REST Redis client dependency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| redisUrl = Environment.getenv("REDIS_URL"); | ||
| } | ||
| jedis = new UnifiedJedis(redisUrl); | ||
| jedis = new RedisAdapter(RedisClient.create(redisUrl)); |
| } | ||
| yield new RedisCache<>(parameters, mapper); | ||
| } | ||
| case "rest_redis" -> new RestRedisCache<>(parameters, mapper); |
| } | ||
| case "rest_redis" -> new RestRedisCache<>(parameters, mapper); | ||
| default -> | ||
| throw new IllegalArgumentException("Unknown cache type: " + type + ". Supported types: local, redis"); |
Comment on lines
+43
to
+44
| if (!redis.ping()) { | ||
| throw new IllegalStateException("Could not connect to redis"); |
| } | ||
|
|
||
| public boolean exists(String key) { | ||
| return jedis.exists(key); |
Comment on lines
+27
to
+29
| @BeforeEach | ||
| public void setup() { | ||
| restCache = new RestRedisCache<>(cacheParameter, new ObjectMapper()); |
dfuchss
reviewed
May 28, 2026
| redisUrl = Environment.getenv("REDIS_URL"); | ||
| } | ||
| jedis = new UnifiedJedis(redisUrl); | ||
| jedis = new RedisAdapter(RedisClient.create(redisUrl)); |
| return switch (type) { | ||
| case LOCAL_CACHE_NAME -> new LocalCache<>(cacheDir, parameters); | ||
| case "redis" -> new RedisCache<>(parameters, mapper); | ||
| return switch (type.toLowerCase()) { |
| jedis = new UnifiedJedis(redisUrl); | ||
| jedis = new RedisAdapter(RedisClient.create(redisUrl)); | ||
| // Check if connection is working | ||
| jedis.ping(); |
There was a problem hiding this comment.
check whether this is now a valid check for ping after you use the adapter
|
|
||
| /** | ||
| * Integration test for the REST Redis interface. | ||
| * TODO: maybe testcontainer or something? |
There was a problem hiding this comment.
you can look into the rest-redis repo for examples with testcontainers
Comment on lines
+116
to
+120
| <dependency> | ||
| <groupId>org.fuchss</groupId> | ||
| <artifactId>rest-redis</artifactId> | ||
| <version>0.1.4</version> | ||
| </dependency> |
There was a problem hiding this comment.
Remove jedis (because rest-redis has the jedis dependency already) :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…torage